package com.cn.serverline.lineicp.productionLine.controller;

import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import javax.annotation.Resource;
import javax.validation.Valid;

import com.cn.serverline.lineicp.productionLine.param.ModelNodeLibraryAddParam;
import com.cn.serverline.lineicp.productionLine.param.ModelNodeLibraryEditParam;
import com.cn.serverline.lineicp.productionLine.param.ModelNodeLibraryIdParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.cn.serverline.lineicp.productionLine.entity.ModelNodeLibrary;
import com.cn.serverline.lineicp.productionLine.service.IModelNodeLibraryService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 型号节点库表 接口
 *
 * @author Gmr
 * @since 2024-07-29
 */
@RestController
@ApiResource(name = "型号节点库的接口")
@Api(tags = "型号节点库")
@Validated
public class ModelNodeLibraryController {

    @Resource(name = "ModelNodeLibraryServiceImpl")
    private IModelNodeLibraryService iModelNodeLibraryService;

    /**
     * 批量添加型号节点库
     */
    @ApiOperation(value = "批量添加型号节点库")
    @PostResource(name = "添加型号节点库", path = "/productionLine/modelNodeLibrary/addBatch")
    public ResponseData<?> addBatch(@RequestBody @Valid List<ModelNodeLibraryAddParam> modelNodeLibrary){
        iModelNodeLibraryService.addBatch(modelNodeLibrary);
        return new SuccessResponseData<>();
    }

    /**
     * 删除型号节点库
     */
    @ApiOperation(value = "删除型号节点库")
    @PostResource(name = "删除型号节点库", path = "/productionLine/modelNodeLibrary/delete")
    public ResponseData<?> delete(@RequestBody @Valid ModelNodeLibraryIdParam id){
        iModelNodeLibraryService.del(id);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑型号节点库
     */
    @ApiOperation(value = "编辑型号节点库")
    @PostResource(name = "编辑型号节点库", path = "/productionLine/modelNodeLibrary/edit")
    public ResponseData<?> edit(@RequestBody @Valid ModelNodeLibraryEditParam modelNodeEditParam) {
        iModelNodeLibraryService.edit(modelNodeEditParam);
        return new SuccessResponseData<>();
    }

    /**
     * 查询-型号节点库表列表
     */
    @ApiOperation(value = "查询-型号节点库表列表")
    @GetResource(name = "查询-型号节点库表列表", path = "/productionLine/modelNodeLibrary/select")
    public ResponseData<List<Map<String, Object>>> select(ModelNodeLibrary modelNodeLibrary) {
        return new SuccessResponseData<>(iModelNodeLibraryService.select(modelNodeLibrary));
    }

    /**
     * 设置为默认
     */
    @ApiOperation(value = "设置默认")
    @PostResource(name = "设置默认", path = "/productionLine/modelNodeLibrary/markDefault")
    public ResponseData<?> markDefault(@RequestBody @Valid ModelNodeLibraryIdParam id){
        iModelNodeLibraryService.markDefault(id);
        return new SuccessResponseData<>();
    }

}
